<template>
  商品列表：
  <hr>
  <ul>
    <li v-for="el in friutArr">
      名称：{{el.name}}，
      价格：{{el.price}}元/斤,
      库存：{{el.num}}斤
    </li>
  </ul>
  <hr>
  <button @click="addGoods">添加一个商品</button>
  <button @click="next">下一页</button>
</template>

<script setup>
import { ref } from 'vue';

const friutArr = ref([
  {name:"苹果",price:2,num:200},
  {name:"鸭梨",price:1.5,num:300},
  {name:"葡萄",price:3,num:50}
])

const addGoods=()=>{
  friutArr.value.unshift({name:"香蕉",price:5,num:1000});
}
const next=()=>{
  friutArr.value=[
  {name:"苹2果",price:2,num:200},
  {name:"鸭2梨",price:1.5,num:300}
  ];
}

</script>

<style lang="scss" scoped>

</style>